import java.util.StringTokenizer;
import java.util.Vector;


class P883_39643 {

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}
	
	public static void main(String[] args) {
		
		int cases = Integer.parseInt(readLn());
		
		for (int k = 0; k < cases; k++) {
			readLn();
			process();
			
			if (k + 1 != cases) System.out.println();
		}
		
	}

	private static void process() {
		int numberOfRectangles = Integer.parseInt(readLn());
		
		Rectangle883[] rectangles = new Rectangle883[numberOfRectangles];
		
		for (int k = 0; k < numberOfRectangles; k++) {
			
			StringTokenizer st = new StringTokenizer(readLn());
			
			double x1 = new Double(st.nextToken()).doubleValue();
			double y1 = new Double(st.nextToken()).doubleValue();
			double x2 = new Double(st.nextToken()).doubleValue();
			double y2 = new Double(st.nextToken()).doubleValue();
		
			double xll = Math.min(x1, x2);
			double yll = Math.min(y1, y2);
			
			double xur = Math.max(x1, x2);
			double yur = Math.max(y1, y2);
			
			rectangles[k] = new Rectangle883(xll, yll, xur, yur);
			
		}
		
		int numberOfLines = Integer.parseInt(readLn());
		
		for (int k = 0; k < numberOfLines; k++) {
			process(rectangles);
		}
		
		
	}

	private static void process(Rectangle883[] rectangles) {
		
		double y = new Double(readLn()).doubleValue();

		boolean[] rectanglesIntersected = new boolean[rectangles.length];
		
		boolean findAnyRectangleIntersected = false;
		
//		System.out.println(y);
		
		for (int k = 0; k < rectanglesIntersected.length; k++) {
//			System.out.println(rectangles[k]);
			
			if ( y > rectangles[k].y1 && y < (rectangles[k].y2)) {
				rectanglesIntersected[k] = true;
				findAnyRectangleIntersected = true;
			} 
			
//			System.out.println(rectanglesIntersected[k]);
			
		}
		
		if (!findAnyRectangleIntersected) {
			System.out.println("0");
			return;
		}
		
		Vector v = new Vector(rectangles.length);
		
		for (int k = 0; k < rectangles.length; k++) {
			if (rectanglesIntersected[k]) {
				v.addElement(new Ponto(rectangles[k].x1, true));
				v.addElement(new Ponto(rectangles[k].x2, false));
			}
		}
		
		
//		for (int k = 0; k < rectangles.length; k++) {
//			for (int j = k + 1; j < rectangles.length; j++) {
//				if (rectangles[k].x >= rectangles[j].x) {
//					Rectangle883 aux = rectangles[k];
//					rectangles[k] = rectangles[j];
//					rectangles[j] = aux;
//				}
//			}
//		}
		
		ordena(v);
		
//		System.out.println(v);
		
		
		int count = 0;
		double x = 0;
		double x1 = 0, x2 = 0;
		int max = -1;
		
		for (int k = 0; k < v.size(); k++) {
			
			Ponto p = (Ponto) v.elementAt(k);
			
			if (p.inicio) {
				x = p.x;
				count++;
			} else {
				if (count > max) {
					max = count;
					x1 = x;
					x2 = p.x;
				}
				count--;
			}
		}
		
		
		System.out.println(max + " " + round(x1,2) + " " + round(x2, 2));
		
	}
	
	static String round(double valor, int casas) {
		long numero = Math.round(valor * Math.pow(10, casas));
		
		String retorno;
		if (numero < 0) retorno = "-";
		else retorno = "";
		retorno += (Math.abs(numero) / (long) Math.pow(10, casas));
		retorno += ".";
		String resto = "" + (Math.abs(numero) % (long) Math.pow(10, casas));
		resto = str('0', casas - resto.length()) + resto;
		retorno += resto;
		
		return retorno;
	}
	
	static String str(char ch, int n) {
		String resultado = "";
		for (int i = 0; i < n; i++) {
			resultado += ch;
		}
		return resultado;
	}

	
	static void ordena(Vector lista) {
		for (int i = 1; i < lista.size(); i++) {
			for (int j = lista.size() - 1; j >= i; j--) {
				Ponto p1 = (Ponto) lista.elementAt(j - 1);
				Ponto p2 = (Ponto) lista.elementAt(j);
				
				if (p1.compareTo(p2) > 0) {
					lista.setElementAt(p2, j - 1);
					lista.setElementAt(p1, j);
				}
			}
		}
	}
	
}

class Rectangle883 {
	
	double depth = 0;
	
	double x1, y1, x2, y2, height, width;
	
	public Rectangle883(double xll, double yll, double xur, double yur) {
		
		this.x1 = xll;
		this.y1 = yll;
		this.x2 = xur;
		this.y2 = yur;
		this.width = xur - x1;
		this.height = yur - y1;
		
	}
	
}

class Ponto {
	
	double x;
	boolean inicio;
	
	Ponto(double x, boolean inicio) {
		this.x = x;
		this.inicio = inicio;
	}
	
	public String toString() {
		return x + " " + inicio;
	}
	
	public int compareTo(Object o) {
		Ponto p = (Ponto) o;
		
		long pV = Math.round(p.x * 100000);
		long tV = Math.round(this.x * 100000);
		
		return (int) (tV - pV);
	}

	
}